import {
  Controller,
  Get,
  Post,
  Body,
  Param,
  Delete,
  Query,
  Put,
} from '@nestjs/common';
import { CateService } from './cate.service';

@Controller('cates')
export class ClassificationController {
  constructor(private readonly ClassificationService: CateService) {}
  @Post()
  create(@Body() createData) {
    return this.ClassificationService.create(createData);
  }

  @Post('list')
  findAll(@Body() createData) {
    return this.ClassificationService.findAll({ ...createData });
  }

  @Get(':id')
  findOne(@Param('id') id: number) {
    return this.ClassificationService.findOne({ id });
  }

  @Put()
  update(@Body() updateData) {
    const { name, id } = updateData;
    return this.ClassificationService.update({
      where: { id: +id },
      data: { name },
    });
  }

  @Delete()
  remove(@Query('id') id: number) {
    return this.ClassificationService.delete({ id });
  }
}
